<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
		<meta name="author" content="金西振" />
		<title></title>
		<style></style>
	</head>
	<body>
		<button id="btn1" class="btn1" onclick="fn1()">按钮1</button>
		<button id="btn2">按钮2</button>

		<input type="text" disabled />
		<script>
			var btn1 = document.getElementById('btn1');
			var btn2 = document.getElementById('btn2');
			// btn1.className = '';

			var index = 0;
			function fn1() {
				console.log('事件');
				if (index === 6) {
					// return;  // 使用return结束了函数，事件依然存在
					btn1.onclick = null; // 移除标签添加的事件
				}
				index++;
				// console.log('index: ', index);
			}

			// 把标签的onclick属性设置null可以把方式一和方式二添加的事件移除

			// btn1.onclick = null;
			// console.log(btn1.onclick);

			btn2.onclick = function () {
				console.log('btn2');
				btn2.onclick = null;
				btn2.disabled = true;
			};
		</script>
	</body>
</html>
